/**
 * Created by zhuyufeng on 2016/1/9.
 */
Ext.define('commitHistroymodel', {
	extend: 'Ext.data.Model',
	fields: [ 'date','num','msg']
});
var commitHistroyStore = Ext.create('Ext.data.Store', {
	model: 'commitHistroymodel',
	autoLoad: true,
	pageSize: 4,
	proxy: {
		type: 'ajax',
		url : './json/commitHistory',
		reader: {
			type: 'json',
			root: 'rows',
			totalProperty: 'total'
		}
	}
});
var commitHistroy = Ext.create('Ext.grid.Panel', {
	store: commitHistroyStore,
	columnWidth:.8,
	region:'east',
	split:true,
	border:true,
	collapsible:true,
	width:400,
	minSize:400,
	maxSize:600,
	title: '违规信息历史记录',
	columns: [
		{text: '日期',width: 100,dataIndex: 'date'},
		{text: '寝室号',width: 150,dataIndex: 'num'},
		{text: '违规信息',width: 150,dataIndex: 'msg'}
	],
	dockedItems:[{
		xtype:'pagingtoolbar',
		store:commitHistroyStore,
		dock:'bottom',
		displayInfo:true,
		displayMsg:'第{0}条到第{1}条,一共{2}条',
		emptyMsg:'没有记录'
	}],
	tbar:[{
		text:'筛选',
		xtype:'button',
		arrowAlign:'right',
		menu:[
			{
				text:'通过时间筛选',
				handler:function(){
					var add_winForm =  Ext.create('Ext.form.Panel', {
						frame: true,   //frame属性
						width: 340,
						bodyPadding:5,
						fieldDefaults: {
							labelAlign: 'left',
							labelWidth: 90,
							anchor: '100%'
						},
						items: [{
							//日期文本框
							xtype: 'datefield', //8
							name: 'date',
							fieldLabel: '日期',
							value: new Date()
						}]
					});
					var syswin = Ext.create('Ext.window.Window',{
						title : "筛选",
						width : 350,
						iconCls : "addicon",
						resizable : false,         	// 不可以随意改变大小
						draggable:false,            // 是否可以拖动
						collapsible : true,         // 允许缩放条
						closeAction : 'close',
						closable : true,
						modal : 'true',             // 弹出模态窗体
						buttonAlign : "center",
						bodyStyle : "padding:0 0 0 0",
						items : [add_winForm],
						buttons : [{
							text : "确定",
							minWidth : 70,
							handler : function() {
								syswin.close();
							}
						}, {
							text : "关闭",
							minWidth : 70,
							handler : function() {
								syswin.close();
							}
						}]
					});
					syswin.show();
				}
			},{
				text:'通过寝室号筛选',
				handler:function(){
					var add_winForm =  Ext.create('Ext.form.Panel', {
						frame: true,   //frame属性
						width: 340,
						bodyPadding:5,
						fieldDefaults: {
							labelAlign: 'left',
							labelWidth: 90,
							anchor: '100%'
						},
						items: [{
							xtype: 'textfield', //3
							name: 'num',
							fieldLabel: '寝室号',
							allowBlank: true,//必填项
							emptyText:'请输入寝室号',
							blankText:"提示"//提示的内容
						}]
					});
					var syswin = Ext.create('Ext.window.Window',{
						title : "筛选",
						width : 350,
						iconCls : "addicon",
						resizable : false,         	// 不可以随意改变大小
						draggable:false,            // 是否可以拖动
						collapsible : true,         // 允许缩放条
						closeAction : 'close',
						closable : true,
						modal : 'true',             // 弹出模态窗体
						buttonAlign : "center",
						bodyStyle : "padding:0 0 0 0",
						items : [add_winForm],
						buttons : [{
							text : "确定",
							minWidth : 70,
							handler : function() {
								syswin.close();
							}
						}, {
							text : "关闭",
							minWidth : 70,
							handler : function() {
								syswin.close();
							}
						}]
					});
					syswin.show();
				}
			}]
	}]
});
